package com.cmower.dzone.optional;

import java.util.Optional;

public class SetGetDefaultValueOptionalDemo {
    public static void main(String[] args) {
String nullName = null;
String name = Optional.ofNullable(nullName).orElse("沉默王二");
System.out.println(name);

String name1 = Optional.ofNullable(nullName).orElseGet(()->"沉默王二");
System.out.println(name1);


    }

}
